﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace APNS.NET
{
    public class Feedback
    {

        public DeviceToken DeviceToken { get; private set; }
        public DateTime Timestamp { get; private set; }

        public static Feedback FromBytes(byte[] bytes)
        {
            if (bytes == null) 
                throw new ArgumentNullException("bytes");

            int seconds = BitConverter.ToInt32(bytes, 0);
            return new Feedback()
                       {
                           Timestamp = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(seconds),
                           DeviceToken = DeviceToken.FromBytes(bytes, 6)
                       };
        }

    }
}
